package offer.secnod;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Offer03 {

    int find(int[] nums) {


        HashMap<Integer, Boolean> integerBooleanHashMap = new HashMap<>();

        for (int a : nums) {
            integerBooleanHashMap.put(a, integerBooleanHashMap.containsKey(a));
        }

//        Collection<Boolean> values = integerBooleanHashMap.values();
//        Iterator<Boolean> iterator = values.iterator();
//        while (iterator.hasNext()){
//
//
//
//        }
        Iterator<Map.Entry<Integer, Boolean>> iterator = integerBooleanHashMap.entrySet().iterator();

        while (iterator.hasNext()) {
            Map.Entry<Integer, Boolean> next = iterator.next();
            if (next.getValue()) {
                return next.getKey();
            }


        }


        return -1;


    }

    public static void main(String[] args) {

        Offer03 offer03 = new Offer03();
        int[] arr={2, 3, 1, 0, 2, 5, 3};
        System.out.println(offer03.find(arr));

    }

}
